﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOAModels;
using TarreOA.TarreOABLL;

public partial class AfficheInform_AfficheInformInfo : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
        if(!Page.IsPostBack) {
            if(Request.QueryString.Get("ai_id") != null) {
                int ai_id = int.Parse(Request.QueryString.Get("ai_id"));
                AfficheInformtbService aiService = new AfficheInformtbService();
                AfficheInformtb ai = aiService.findById(ai_id);
                if(ai != null) {
                    User curLoginUser = (User) Session["user"];
                    string finishUsersid = ai.AfficheInformFinishUsersid;
                    string unfinishUsersid = ai.AfficheInformUnFinishUsersid;
                    unfinishUsersid = unfinishUsersid.Replace("," + curLoginUser.UserId + ",", ",");
                    string curuserid = "," + curLoginUser.UserId + ",";
                    if(finishUsersid.IndexOf(curuserid) < 0)
                    {
                        finishUsersid = finishUsersid + curLoginUser.UserId + ",";
                    }
                    if(aiService.updateFinishAndUnFinishUsersid(ai_id, finishUsersid, unfinishUsersid) == 1) {
                        this.LblTitle.Text = ai.AfficheInformTitle;
                        this.LblCreateTime.Text = ai.AfficheInformSendUser.UserName + " 发表于:" + ai.AfficheInformCreateTime.ToString();
                        this.LblContent.Text = ai.AfficheInformContent;
                    }
                }
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e) {
        Response.Redirect("Index.aspx");
    }
}
